import { Inject, Controller, Post, Body } from '@midwayjs/decorator';
import { Context } from '@midwayjs/koa';
import { User } from '../entity/user';
import { UserService } from '../service/user.service';

@Controller('/user')
export class UserController {
  @Inject()
  ctx: Context;

  @Inject()
  userService: UserService;

  @Post('/register')
  async register(@Body() user: User): Promise<any> {
    const result = await this.userService.register(user);
    return result;
  }

  @Post('/login')
  async login(@Body() user: User): Promise<any> {
    const result = await this.userService.login(user);
    return result;
  }
}
